package LuoGu.数据结构顺序表.后缀表达式;

import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String temp = s.nextLine();
        Stack<Integer> stack1 = new Stack<>();
        int index = 0;
        for(int i=0;i<temp.length();i++){
            char tempc = temp.charAt(i);
            if(tempc=='.'){
                stack1.push(Integer.valueOf(temp.substring(index,i)));
                index = i+1;
            }
            else if(tempc=='+'){
                int a = stack1.pop();
                int b = stack1.pop();
                stack1.push(a+b);
                index = i+1;
            }
            else if(tempc=='*'){
                int a = stack1.pop();
                int b = stack1.pop();
                stack1.push(a*b);
                index = i+1;
            }else if(tempc=='-'){
                int a = stack1.pop();
                int b = stack1.pop();
                stack1.push(b-a);
                index = i+1;
            }else if(tempc=='/'){
                int a = stack1.pop();
                int b = stack1.pop();
                stack1.push(b/a);
                index = i+1;
            }
        }System.out.println(stack1.pop());
    }
}
